
<template>
    <div class="page">
        <scroll-view scroll-y class="page">
            <div class="tudev">
                <div
                    v-if="token&&token.imageUrl"
                    @click="toMessage"
                    class="weui-media-box weui-media-box_appmsg myclasstop"
                    hover-class="weui-cell_active"
                >
                    <div class="weui-media-box__hd weui-media-box__hd_in-appmsg">
                        <image class="weui-media-box__thumb" :src="token.imageUrl" />
                    </div>
                    <div
                        class="weui-media-box__bd weui-media-box__bd_in-appmsg"
                        style="text-align: left"
                    >
                        <div class="weui-media-box__title">{{token.nickName||'--'}}</div>
                        <div class="weui-media-box__title ipone">{{token.mobile}}</div>
                    </div>
                    <!-- <div style="background: url('') no-repeat center center;background-size: 100%;" class=""></div> -->
                    <img
                        src="../../static/17.png"
                        class="weui-cell__ft weui-cell__ft_in-tubiaoa"
                        alt
                    />
                </div>
                <div v-else class="myclasstop">
                    <button
                        class="login_btn_t"
                        @getuserinfo="handleClick"
                        open-type="getUserInfo"
                    >微信授权</button>
                </div>
                <div class="mytop_img_body">
                    <img class="mytop_img" src="../../static/vipcard.png" alt />
                </div>
            </div>
            <div
                class="tudevs"
                :style="moveDataTouch"
                @touchstart="startMoveEvent"
                @touchmove="ballMoveEvent"
                @touchend="tapMoveEvent"
            >
                <div class="top_backround_img">
                    <img class="top_backround_img" src="../../static/huxian@2x.png" alt />
                </div>
                <div class="top_backround_img_body">
                    <!--<div class="myOelder">
                        <div class="weui-cell weui-cell_access">
                            <div class="weui-cell__bd weui-cell__bd_oelder">
                                <div style="display: inline-block; vertical-align: middle;">医院服务</div>
                            </div>
                        </div>
                        <div class="listTops">
                            <div class="listBody" @click="myorld('无')">
                                <div>
                                    <img class="listBody_img" src="../../static/btn_course.png" alt />
                                </div>
                                <div class="listBody_size">我的课堂</div>
                            </div>
                            <div class="listBody" @click="myorld('无')">
                                <div>
                                    <img
                                        class="listBody_img"
                                        src="../../static/btn_booking.png"
                                        alt
                                    />
                                </div>
                                <div class="listBody_size">我的预约</div>
                            </div>
                            <div class="listBody" @click="myorld('无')">
                                <div>
                                    <img
                                        class="listBody_img"
                                        src="../../static/btn_mydoctor.png"
                                        alt
                                    />
                                </div>
                                <div class="listBody_size">我的医生</div>
                            </div>
                        </div>
                    </div>
                    <div class="myOelder myOelder_top">
                        <div class="weui-cell weui-cell_access">
                            <div class="weui-cell__bd weui-cell__bd_oelder">
                                <div style="display: inline-block; vertical-align: middle;">我的服务</div>
                            </div>
                        </div>
                        <div class="listTop">
                            <div class="listBody" @click="myorld('pages/classify/index')">
                                <div>
                                    <img class="listBody_img" src="../../static/20.png" alt />
                                </div>
                                <div class="listBody_size">租赁服务</div>
                            </div>
                            <div class="listBody" @click="myorld('监护服务')">
                                <div>
                                    <img class="listBody_img" src="../../static/27.png" alt />
                                </div>
                                <div class="listBody_size">监护服务</div>
                            </div>
                            <div class="listBody" @click="myorld('packageB/report')">
                                <div>
                                    <img class="listBody_img" src="../../static/21.png" alt />
                                </div>
                                <div class="listBody_size">监护报告</div>
                            </div>
                            <div class="listBody" @click="myorld('pages/adress/adsList')">
                                <div>
                                    <img class="listBody_img" src="../../static/22.png" alt />
                                </div>
                                <div class="listBody_size">收货地址</div>
                            </div>
                        </div>
                        <div class="listTop">
                            <div class="listBody" @click="myorld('pages/my/orlder')">
                                <div>
                                    <img class="listBody_img" src="../../static/24.png" alt />
                                </div>
                                <div class="listBody_size">我的订单</div>
                            </div>
                        </div>
                    </div> -->
                </div>
            </div>
        </scroll-view>
    </div>
</template>

<script>
import "@/css/weui.css";
export default {
    name: "myhome",
    data() {
        return {
            login: false,
            tine: null,
            tine: null,
            sisx: "男",
            token: {},
            userInfo: {},
            userInfos: {},
            myimageUrl: false,
            touchy: 0,
            moveDataTouch: "",
            top1: 0,
            top2: 0,
            top3: 0,
            top4: 0
        };
    },
    mounted() {
        var _this = this;
        uni.getStorage({
            key: "token",
            success: function(res) {
                if (res.data.token) {
                    _this.token = res.data;
                    if (_this.token.imageUrl) {
                        _this.myimageUrl = true;
                    } else {
                        _this.myimageUrl = false;
                    }
                }
            }
        });
    },
    methods: {
        myorld(itm) {
            if (itm == "监护服务") {
                uni.showModal({
                    title: "提示",
                    cancelText: "关闭",
                    confirmText: "复制名字",
                    content:
                        "小程序暂不支持设备监护，请前去应用商店搜索幸孕妈下载APP完成监护。",
                    success(res) {
                        if (res.confirm) {
                            var self = this;
                            wx.setClipboardData({
                                data: "幸孕妈",
                                success: function(res) {}
                            });
                        } else if (res.cancel) {
                        }
                    }
                });
            } else if (itm == "无") {
                uni.showModal({
                    title: "提示",
                    cancelText: "关闭",
                    confirmText: "确定",
                    content: "该功能正在开发中！",
                    success(res) {
                        if (res.confirm) {
                        } else if (res.cancel) {
                        }
                    }
                });
            } else {
                uni.navigateToMiniProgram({
                    appId: "wxed0a9f405822beff",
                    path: itm,
                    extraData: {
                        foo: "bar"
                    },
                    // envVersion: "develop",
                    success(res) {
                        // 打开成功
                        // console.log('打开成功')
                    }
                });
            }
        },
        startMoveEvent(e) {
            var touchs = e.touches[0];
            var pageY = touchs.pageY;
            this.touchy = pageY;
        },
        ballMoveEvent(e) {
            var _this = this;
            var touchs = e.touches[0];
            var pageY = touchs.pageY;
            uni.getSystemInfo({
                success: function(res) {
                    if (res.platform == "devtools") {
                        if (pageY > _this.touchy) {
                            var page = Number(pageY) - Number(_this.touchy);
                            // console.log('pageY: ' +page)
                            _this.moveDataTouch = "margin-top: -35px";
                        }
                    } else if (res.platform == "ios") {
                    } else if (res.platform == "android") {
                        if (pageY > _this.touchy) {
                            var page = Number(pageY) - Number(_this.touchy);
                            // console.log('pageY: ' +page)
                            _this.moveDataTouch = "margin-top: -35px";
                        }
                    }
                }
            });
        },
        tapMoveEvent(e) {
            this.touchy = 0;
            this.moveDataTouch = "margin-top: -85px";
        },
        toMessage() {
            uni.navigateTo({
                url: "../my/myMessage",
                animationType: "pop-in",
                animationDuration: 200
            });
        },
        handleClick(e) {
            var _this = this;
            _this.userInfo = e.mp.detail.userInfo;
            _this.token.imageUrl = _this.userInfo.avatarUrl;
            if (_this.token.imageUrl) {
                _this.myimageUrl = true;
            } else {
                _this.token.imageUrl = "../../static/logo.png";
                _this.myimageUrl = true;
            }
            _this.token.nickName = _this.userInfo.nickName;
            uni.setStorage({
                //存储到本地
                key: "token",
                data: _this.token
            });
            var datas = {
                id: _this.token.id,
                imageUrl: _this.token.imageUrl,
                nickName: _this.userInfo.nickName
            };
            _this.$ajaxs
                .post("/mobile/v1/users/edite", datas)
                .then(res => {
                    var { status, content } = res;
                    if (status == "200") {
                    } else {
                    }
                })
                .catch(err => {});
        },
        goLogin() {
            if (!this.login) {
                // console.log("点击前往登录");
                uni.navigateTo({
                    url: "../login/login",
                    animationType: "pop-in",
                    animationDuration: 200
                });
            }
        }
    }
};
</script>

<style scope>
.tudev {
    background: #fa4d93;
}

.card {
    padding: 20upx;
}
.weui-media-box__thumb {
    border-radius: 50%;
}
.myclasstop {
    text-align: center;
    padding: 20upx;
    padding-bottom: 10upx;
    height: 150upx;
    background: #fa4d93;
}
.listTop {
    display: flex;
    justify-content: space-between;
    padding: 20upx 0 20upx 0;
    margin: 0 60upx;
}
.listTops {
    display: flex;
    justify-content: space-between;
    padding: 20upx 60upx 40upx 60upx;
}
.listBody {
    text-align: center;
}
.listBody_img {
    width: 64upx;
    height: 64upx;
}
.listBody .listBody_size {
    width: 110upx;
    font-size: 24upx;
    font-weight: 500;
    color: rgba(102, 102, 102, 1);
    line-height: 34upx;
}
.login_btn_t {
    width: 290upx;
    height: 76upx;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 38upx;
    font-size: 32upx;
    font-family: PingFang-SC-Medium;
    font-weight: 500;
    border: none;
    color: rgba(255, 255, 255, 1);
    line-height: 76upx;
}
.hideContent {
    display: none;
}
.page {
    height: 100vh;;
    background: #f8f8f8;
}
/* page {
    height: 100%;
} */
.top_backround_img_body {
    height: 500upx;
}
</style>